	Concentre.objectsHashTable['{http://www.w3.org/2002/xforms}instance'] =
	Concentre.XForms_Element_Head_Instance = Concentre.Class(Concentre.XForms_Element_Head_Abstract, {
		initialize: function () {
 		 	
 		 	this.superclass.initialize.apply(this, arguments);
 		 	
 			var id = this.attributes.id || '#default';
			var src = this.attributes.src;

			var el = this.node;
			
			//var c = XPathContext.create(concentre.document.documentElement);	
			var m = this.parent;

			this.parent.innerInstances.unshift(this);
			
			if (!m.defaultInstance) { 
				m.defaultInstance = this;
			}
			
		
			if (src!=null) {
				//src = new concentre.factory.avt(this.src, c).toString();
		
				this.instanceNode = Concentre.Factory.Xml.loadURL(this.src);	
				if (!this.instanceNode) throw new Concentre.Modules.XForms.Exception(this, 'xforms-link-exception', i18n.translate('IDS_XForms_LINK_EXCEPTION', src));

				var el = this.instanceNode.documentElement;
				this.copyNameSpaces(el);
		
			} else 	if (el==null) {
				throw new Exception(this, concentre.factory.i18n.translate('IDS_INSTANCE_MUST_HAVE_CHILD_NODE', this.id ));
			} else {
			
				var s = Concentre.Factory.Xml.serialize(el);
				this.instanceNode = Concentre.Factory.Xml.load(s);

				QName._namespaces['']=null;
				this.copyNameSpaces(this.instanceNode.documentElement);
			}
			
		},
		
		copyNameSpaces: function(node) {
		
			for (var n in QName._namespaces) {
				var ns = QName._namespaces[n];
	  			var prefix = 'xmlns:'+ n;
		
	  			if (n=='') continue; 
				if (node.getAttribute(prefix)==null) node.setAttribute(prefix,ns);      
			}
			
		},
		
		toString: function() {
			return '[ Object Concentré XForms Instance ]';
		}
	});
